#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT(hitask, [0.0.11], [SounOS@gmail.com])
AC_CONFIG_SRCDIR([src/http.h])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE

# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL

# Checks for libraries.
# FIXME: Replace `main' with a function in `-lchardet':
AC_CHECK_LIB([chardet], [main])
# FIXME: Replace `main' with a function in `-lpcre':
AC_CHECK_LIB([pcre], [main])
# FIXME: Replace `main' with a function in `-lsbase':
AC_CHECK_LIB([sbase], [main])
# FIXME: Replace `main' with a function in `-lz':
AC_CHECK_LIB([z], [main])

# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h fcntl.h locale.h netdb.h stdint.h stdlib.h string.h sys/time.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM
#pthread
havepthread=no
AC_CHECK_LIB(pthread,pthread_create,havepthread=yes)
if test "$havepthread" = "yes" ; then
    CPPFLAGS="${CPPFLAGS} -DHAVE_PTHREAD"
    LDFLAGS="${LDFLAGS} -lpthread"
fi

#iconv
haveiconv=no
AC_CHECK_LIB(iconv, iconv_open, haveiconv=yes)
if test "$haveiconv" = "yes" ; then
    CPPFLAGS="${CPPFLAGS} -DHAVE_ICONV"
    LDFLAGS="${LDFLAGS} -liconv"
fi

AC_CHECK_EXTRA_OPTIONS


# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_LSTAT
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MALLOC
AC_FUNC_MEMCMP
AC_FUNC_MKTIME
AC_FUNC_MMAP
AC_FUNC_REALLOC
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_CHECK_FUNCS([ftruncate gethostbyname gettimeofday inet_ntoa memset mkdir munmap setlocale strcasecmp strchr strdup strerror strncasecmp])

AC_CONFIG_FILES([Makefile
                 doc/Makefile
                 src/Makefile])
AC_OUTPUT
